//
//  PeriodicalDetailViewController.m
//  LiteraryTune
//
//  Created by 神州四达 on 2018/2/5.
//  Copyright © 2018年 cxd. All rights reserved.
//

#import "PeriodicalDetailViewController.h"
#import "NewsPaperTableViewCell.h"
#import "PeroidicalListTableViewCell.h"
#import "HasMoreTableViewCell.h"
#import "PeriodicalSiftTableViewCell.h"

@interface PeriodicalDetailViewController () <UITableViewDelegate,UITableViewDataSource>

@property (nonatomic, strong)UITableView *tableView;



@end

@implementation PeriodicalDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"期刊";
    [self buildUI];
}

- (void)buildUI {
//    [self.view addSubview:self.tableView];
    
}

#pragma mark - 懒加载

- (UITableView *)tableView {
    if (!_tableView) {
        _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kScreenHeight - 64) style:UITableViewStylePlain];
        _tableView.delegate = self;
        _tableView.dataSource = self;
        _tableView.showsVerticalScrollIndicator = NO;
        _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([NewsPaperTableViewCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([NewsPaperTableViewCell class])];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([PeriodicalSiftTableViewCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([PeriodicalSiftTableViewCell class])];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([PeroidicalListTableViewCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([PeroidicalListTableViewCell class])];
        [_tableView registerNib:[UINib nibWithNibName:NSStringFromClass([HasMoreTableViewCell class]) bundle:nil] forCellReuseIdentifier:NSStringFromClass([HasMoreTableViewCell class])];
    }
    return _tableView;
}

#pragma mark - 协议实现
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 10;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        NewsPaperTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([NewsPaperTableViewCell class])];
        return cell;
    }
    if (indexPath.row == 1) {
        PeriodicalSiftTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PeriodicalSiftTableViewCell class])];
        return cell;
    }
    if (indexPath.row == 9) {
        HasMoreTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([HasMoreTableViewCell class])];
        cell.moreBtn.layer.borderColor = [UIColor colorFromHexCode:@"#eeeeee"].CGColor;
        cell.moreBtn.layer.borderWidth = 1.f;
        cell.moreBtn.layer.cornerRadius = 4.f;
        cell.moreBtn.layer.masksToBounds = YES;
        return cell;
    }
    PeroidicalListTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:NSStringFromClass([PeroidicalListTableViewCell class])];
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath {
    if (indexPath.row == 0) {
        return 300;
    }
    if (indexPath.row == 1) {
        return 60;
    }
    if (indexPath.row == 9) {
        return 60;
    }
    return 100;
}

@end
